namespace t
{
    const NUM = 10000000;

    const array: number[] = [];
    array.length = NUM;
    array.fill(1);
    
    const float32Array = new Float32Array(NUM);
    float32Array.fill(1);

    test('Float32Array', float32Array);
    test('Array', array);

    function test(label: string, array: number[] | Float32Array)
    {
        console.group(label);

        console.time('fill');
        array.fill(1);
        console.timeEnd('fill')

        console.time('for');
        for (let i = 0; i < NUM; i++)
        {
            array[i] = 1;
        }
        console.timeEnd('for')

        console.time('fill');
        array.fill(1);
        console.timeEnd('fill')

        console.time('for');
        for (let i = 0; i < NUM; i++)
        {
            array[i] = 1;
        }
        console.timeEnd('for')

        console.groupEnd();
    }
}